export const debounce = function (fun, delay) {
	return function (args) {
		let that = this
		let _args = args
		clearTimeout(fun.id)
		fun.id = setTimeout(() => {
			fun.call(that, _args)
		}, delay)
	}
}

export const throttle = function (fn, delay) {
	let timer = true
	return function (args) {
		let that = this
		let _args = arguments
		if (!timer) {
			return false
		}
		timer = false
		setTimeout(() => {
			fn.apply(that, _args)
			timer = true
		}, delay)
	}
}
